nexus\api\rtapi/
player.rs1use super::RealTimeData;
2use bitflags::bitflags;
3use std::ffi::CStr;
4
5#[derive(Debug, Clone)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7pub struct PlayerData {
8 pub account_name: String,
10
11 pub character_name: String,
13
14 pub character_position: [f32; 3],
16
17 pub character_facing: [f32; 3],
19
20 pub profession: u32,
22
23 pub elite_specialization: u32,
25
26 pub mount_index: u32,
28
29 pub character_state: CharacterState,
31}
32
33impl PlayerData {
34 pub unsafe fn read(data: *const RealTimeData) -> Self {
39 Self {
40 account_name: CStr::from_ptr((*data).account_name.as_ptr())
41 .to_string_lossy()
42 .into_owned(),
43 character_name: CStr::from_ptr((*data).account_name.as_ptr())
44 .to_string_lossy()
45 .into_owned(),
46 character_position: (*data).character_position,
47 character_facing: (*data).character_facing,
48 profession: (*data).profession,
49 elite_specialization: (*data).elite_specialization,
50 mount_index: (*data).mount_index,
51 character_state: CharacterState::from_bits_retain((*data).character_state),
52 }
53 }
54}
55
56bitflags! {
57 #[derive(
58 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash,
59 )]
60 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
61 pub struct CharacterState : u32 {
62 const IsAlive = 1 << 0;
64
65 const IsDowned = 1 << 1;
67
68 const IsInCombat = 1 << 2;
70
71 const IsSwimming = 1 << 3;
73
74 const IsUnderwater = 1 << 4;
76
77 const IsGliding = 1 << 5;
79
80 const IsFlying = 1 << 6;
82 }
83}